import Point from './Point.js';

export default class React{
    constructor(x,y,width,height){
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }
    isPointInReact(p){
        if(p.x > this.x && p.x < this.x + this.width && p.y > this.y && p.y < this.y + this.height){
            return true;
        }
        else {
            return false;
        }
    }
    isColission(r){
        let p1 = new Point(r.x,r.y);
        let p2 = new Point(r.x + r.width,r.y);
        let p3 = new Point(r.x,r.y + r.height);
        let p4 = new Point(r.x + r.width,r.y + r.height);
        if(this.isPointInReact(p1) || this.isPointInReact(p2) || this.isPointInReact(p3) || this.isPointInReact(p4)){
            return true;
        }
        return false;
    }
}